package com.joker.aigc.oj.service.impl.codesandbox;



import com.joker.aigc.oj.domain.dto.code.ExecuteCodeRequest;
import com.joker.aigc.oj.domain.dto.code.ExecuteCodeResponse;
import com.joker.aigc.oj.service.CodeSandbox;
import com.joker.aigc.oj.service.impl.template.cpp.CppSandboxTemplate;
import com.joker.aigc.oj.service.impl.template.java.JavaSandboxTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


/**
 * 判题的真实路径
 */
@Service
@Slf4j
public class DockerCodeSandbox implements CodeSandbox {


    @Resource
    private JavaSandboxTemplate javaDockerAcmSandbox;


    @Resource
    private CppSandboxTemplate cppNativeAcmSandbox;


    @Override
    public ExecuteCodeResponse executeCode(ExecuteCodeRequest executeCodeRequest) {
        List<String> inputList = executeCodeRequest.getInputList();
        String code = executeCodeRequest.getCode();
        String language = executeCodeRequest.getLanguage();

        switch (language) {
            case "java":
                return javaDockerAcmSandbox.executeJavaCode(inputList, code);
            case "cpp":
                return cppNativeAcmSandbox.executeCppCode(inputList, code);
            default:
                return null;
        }

    }
}
